package com.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ConEmployeeServiceMapper {
    @Insert("insert into con_employee_service(userId, serviceId) values(#{employeeId}, #{serviceId})")
    int addEmployeeService(@Param("employeeId") Integer employeeId, @Param("serviceId") Integer serviceId);

    @Select("select userId from con_employee_service where serviceId = #{serviceId}")
    List<Integer> getEmployeeByServiceId(@Param("serviceId") Integer serviceId);

    @Select("select s.pic from con_employee_service ces join tb_service s on s.id = ces.serviceId where ces.userId = #{employeeId}")
    String getServicePicByUserId(@Param("employeeId") Integer employeeId);

    @Select("select count(userId) from con_employee_service")
    Integer totalEmployee();

    @Delete("delete from con_employee_service where userId = #{id}")
    int deleteById(@Param("id") Integer id);

    @Select("select serviceId from con_employee_service where userId = #{userId}")
    String getServiceIdByUserId(@Param("userId") Integer userId);
}